@echo off


if not exist ..\import\dbattles\*.txt  goto noDbtlsImport

if not exist import  mkdir  import

if not exist extracted\*.bts   call  wiso\eBts.bat

FOR %%i IN (..\import\dbattles\*.txt) DO (
    if exist extracted\%%~ni.bts   ffxbts -i2  -w  -t ffx.tbs  -o import\%%~ni.bts  extracted\%%~ni.bts   %%i
)

if not exist extdec\0170*      call  wiso\eBtsc.bat
if exist import\*.bts  ffxbtsc -i  -o importdec\0170  extdec\0170   2043 2403  import\  .bts


:noDbtlsImport



if not exist ..\import\dbattle\*.txt  goto noDbattleImport

if not exist importdec  mkdir  importdec
if not exist import  mkdir  import


if not exist extdec\*.bt   call  wiso\eBt.bat

FOR %%i IN (..\import\dbattle\*.txt) DO (
    if exist extdec\%%~ni.bt      ffxbt  -i4    -t ffx.tbs  -o importdec\%%~ni.bt  extdec\%%~ni.bt     %%i
    rem duplicit with others, see below
    if exist extdec\%%~ni.bt.dt   ffxbt  -i4    -t ffx.tbs  -o importdec\%%~ni.bt  extdec\%%~ni.bt.dt  %%i
)

rem import those with duplict text, if not exist (not imported)
if not exist "..\import\dbattle\1687.txt"  if exist "..\import\dbattle\1226.txt"  ffxbt -i4   -t ffx.tbs   -o importdec\1687.bt   extdec\1687.bt.dt   "..\import\dbattle\1226.txt"
if not exist "..\import\dbattle\1813.txt"  if exist "..\import\dbattle\1226.txt"  ffxbt -i4   -t ffx.tbs   -o importdec\1813.bt   extdec\1813.bt.dt   "..\import\dbattle\1226.txt"
if not exist "..\import\dbattle\1246.txt"  if exist "..\import\dbattle\1239.txt"  ffxbt -i4   -t ffx.tbs   -o importdec\1246.bt   extdec\1246.bt.dt   "..\import\dbattle\1239.txt"
if not exist "..\import\dbattle\1249.txt"  if exist "..\import\dbattle\1239.txt"  ffxbt -i4   -t ffx.tbs   -o importdec\1249.bt   extdec\1249.bt.dt   "..\import\dbattle\1239.txt"
if not exist "..\import\dbattle\1252.txt"  if exist "..\import\dbattle\1239.txt"  ffxbt -i4   -t ffx.tbs   -o importdec\1252.bt   extdec\1252.bt.dt   "..\import\dbattle\1239.txt"
if not exist "..\import\dbattle\1257.txt"  if exist "..\import\dbattle\1256.txt"  ffxbt -i4   -t ffx.tbs   -o importdec\1257.bt   extdec\1257.bt.dt   "..\import\dbattle\1256.txt"
if not exist "..\import\dbattle\1258.txt"  if exist "..\import\dbattle\1256.txt"  ffxbt -i4   -t ffx.tbs   -o importdec\1258.bt   extdec\1258.bt.dt   "..\import\dbattle\1256.txt"
if not exist "..\import\dbattle\1259.txt"  if exist "..\import\dbattle\1256.txt"  ffxbt -i4   -t ffx.tbs   -o importdec\1259.bt   extdec\1259.bt.dt   "..\import\dbattle\1256.txt"
if not exist "..\import\dbattle\1260.txt"  if exist "..\import\dbattle\1256.txt"  ffxbt -i4   -t ffx.tbs   -o importdec\1260.bt   extdec\1260.bt.dt   "..\import\dbattle\1256.txt"
if not exist "..\import\dbattle\1261.txt"  if exist "..\import\dbattle\1256.txt"  ffxbt -i4   -t ffx.tbs   -o importdec\1261.bt   extdec\1261.bt.dt   "..\import\dbattle\1256.txt"
if not exist "..\import\dbattle\1262.txt"  if exist "..\import\dbattle\1256.txt"  ffxbt -i4   -t ffx.tbs   -o importdec\1262.bt   extdec\1262.bt.dt   "..\import\dbattle\1256.txt"
if not exist "..\import\dbattle\1274.txt"  if exist "..\import\dbattle\1273.txt"  ffxbt -i4   -t ffx.tbs   -o importdec\1274.bt   extdec\1274.bt.dt   "..\import\dbattle\1273.txt"
if not exist "..\import\dbattle\1275.txt"  if exist "..\import\dbattle\1273.txt"  ffxbt -i4   -t ffx.tbs   -o importdec\1275.bt   extdec\1275.bt.dt   "..\import\dbattle\1273.txt"
if not exist "..\import\dbattle\1298.txt"  if exist "..\import\dbattle\1273.txt"  ffxbt -i4   -t ffx.tbs   -o importdec\1298.bt   extdec\1298.bt.dt   "..\import\dbattle\1273.txt"
if not exist "..\import\dbattle\1299.txt"  if exist "..\import\dbattle\1273.txt"  ffxbt -i4   -t ffx.tbs   -o importdec\1299.bt   extdec\1299.bt.dt   "..\import\dbattle\1273.txt"
if not exist "..\import\dbattle\1300.txt"  if exist "..\import\dbattle\1273.txt"  ffxbt -i4   -t ffx.tbs   -o importdec\1300.bt   extdec\1300.bt.dt   "..\import\dbattle\1273.txt"
if not exist "..\import\dbattle\1301.txt"  if exist "..\import\dbattle\1273.txt"  ffxbt -i4   -t ffx.tbs   -o importdec\1301.bt   extdec\1301.bt.dt   "..\import\dbattle\1273.txt"
if not exist "..\import\dbattle\1305.txt"  if exist "..\import\dbattle\1273.txt"  ffxbt -i4   -t ffx.tbs   -o importdec\1305.bt   extdec\1305.bt.dt   "..\import\dbattle\1273.txt"
if not exist "..\import\dbattle\1306.txt"  if exist "..\import\dbattle\1273.txt"  ffxbt -i4   -t ffx.tbs   -o importdec\1306.bt   extdec\1306.bt.dt   "..\import\dbattle\1273.txt"
if not exist "..\import\dbattle\1307.txt"  if exist "..\import\dbattle\1273.txt"  ffxbt -i4   -t ffx.tbs   -o importdec\1307.bt   extdec\1307.bt.dt   "..\import\dbattle\1273.txt"
if not exist "..\import\dbattle\1308.txt"  if exist "..\import\dbattle\1273.txt"  ffxbt -i4   -t ffx.tbs   -o importdec\1308.bt   extdec\1308.bt.dt   "..\import\dbattle\1273.txt"
if not exist "..\import\dbattle\1311.txt"  if exist "..\import\dbattle\1273.txt"  ffxbt -i4   -t ffx.tbs   -o importdec\1311.bt   extdec\1311.bt.dt   "..\import\dbattle\1273.txt"
if not exist "..\import\dbattle\1988.txt"  if exist "..\import\dbattle\1348.txt"  ffxbt -i4   -t ffx.tbs   -o importdec\1988.bt   extdec\1988.bt.dt   "..\import\dbattle\1348.txt"
if not exist "..\import\dbattle\1380.txt"  if exist "..\import\dbattle\1377.txt"  ffxbt -i4   -t ffx.tbs   -o importdec\1380.bt   extdec\1380.bt.dt   "..\import\dbattle\1377.txt"
if not exist "..\import\dbattle\1387.txt"  if exist "..\import\dbattle\1377.txt"  ffxbt -i4   -t ffx.tbs   -o importdec\1387.bt   extdec\1387.bt.dt   "..\import\dbattle\1377.txt"
if not exist "..\import\dbattle\1554.txt"  if exist "..\import\dbattle\1546.txt"  ffxbt -i4   -t ffx.tbs   -o importdec\1554.bt   extdec\1554.bt.dt   "..\import\dbattle\1546.txt"
if not exist "..\import\dbattle\1632.txt"  if exist "..\import\dbattle\1631.txt"  ffxbt -i4   -t ffx.tbs   -o importdec\1632.bt   extdec\1632.bt.dt   "..\import\dbattle\1631.txt"
if not exist "..\import\dbattle\1634.txt"  if exist "..\import\dbattle\1631.txt"  ffxbt -i4   -t ffx.tbs   -o importdec\1634.bt   extdec\1634.bt.dt   "..\import\dbattle\1631.txt"
if not exist "..\import\dbattle\1636.txt"  if exist "..\import\dbattle\1631.txt"  ffxbt -i4   -t ffx.tbs   -o importdec\1636.bt   extdec\1636.bt.dt   "..\import\dbattle\1631.txt"
if not exist "..\import\dbattle\1637.txt"  if exist "..\import\dbattle\1631.txt"  ffxbt -i4   -t ffx.tbs   -o importdec\1637.bt   extdec\1637.bt.dt   "..\import\dbattle\1631.txt"
if not exist "..\import\dbattle\1638.txt"  if exist "..\import\dbattle\1631.txt"  ffxbt -i4   -t ffx.tbs   -o importdec\1638.bt   extdec\1638.bt.dt   "..\import\dbattle\1631.txt"


:noDbattleImport

